package com.lll.securitydemo.web;

import com.lll.securitydemo.dto.entity.UserEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * Description: <br/>
 *
 * @author LLL<br                               />;
 * @taskId <br/>
 * <br/>
 */
@Controller
public class MainController {

    @RequestMapping("/")
    public String root() {
        return "redirect:/index";
    }

    @RequestMapping("index")
    public String index() {
        return "index";
    }

    @RequestMapping("login")
    public String login() {
        return "login";
    }

    @RequestMapping("/login-error")
    public String loginError(Model model) {
        model.addAttribute("loginError", true);
        return "login";
    }

    @GetMapping("401")
    public String accessDenied() {
        return "401";
    }

    @GetMapping("/user/common")
    public String common() {
        return "user/common";
    }

    @GetMapping("user/admin")
    public String admin() {
        return "user/admin";
    }

    @GetMapping("/user/dertail")
    public String detail(Model model) {
        UserEntity userEntity = new UserEntity(10L, "WJY", "123456");
        model.addAttribute("userEntity", userEntity);
        return "user/common";
    }

}
